import time

from base.base import Base

import page


class Page_Cart(Base):
    # 回到首页
    def page_cart_home_page(self):
        self.base_home_page(page.shop_home_page)

    # 输入iPhone
    def page_cart_insert_phone(self):
        self.base_input_element(page.shop_cart_input, "iphone")

    # 点击搜索
    def page_cart_serach_click(self):
        self.base_click_element(page.shop_cart_click_search)

    # 第一次加入购物车
    def page_cart_insert_one(self):
        self.base_click_element(page.shop_cart_insert_goods)

    def page_cart_two(self):
        self.base_click_element(page.shop_cart_two_insert_goods)

    # 加入frame标签
    def page_cart_frame(self):
        time.sleep(5)
        # self.base_switch_frame(page.shop_cart_frame)
        self.base_switch_frame(self.base_find_element(page.shop_cart_frame_id))
        return self.base_get_text(page.shop_cart_assert)

    # 关闭窗口
    def page_cart_close_win(self):
        self.base_frame_content()
        self.base_click_element(page.shop_cart_close_win)
    # 组合业务
    def page_insert_goods(self):
        self.page_cart_home_page()
        self.page_cart_insert_phone()
        self.page_cart_serach_click()
        self.page_cart_insert_one()
        self.page_cart_two()
        # self.page_cart_close_win()
